<!--
  ~ Copyright 2021 Red Hat, Inc. and/or its affiliates.
  ~
  ~ Licensed under the Apache License, Version 2.0 (the "License");
  ~ you may not use this file except in compliance with the License.
  ~ You may obtain a copy of the License at
  ~
  ~       http://www.apache.org/licenses/LICENSE-2.0
  ~
  ~ Unless required by applicable law or agreed to in writing, software
  ~ distributed under the License is distributed on an "AS IS" BASIS,
  ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  ~ See the License for the specific language governing permissions and
  ~ limitations under the License.
  -->

{#if info:isProcessEnabled}
<a href="{urlbase}/processInstances" class="badge badge-light">
    <i class="fa fa-project-diagram fa-fw"></i>
    Process Instances <span id="processInstancesCount" class="badge badge-light"/>
</a>
<br/>
<a href="{urlbase}/tasks" class="badge badge-light">
    <i class="fa fa-tasks fa-fw"></i>
    Tasks <span id="tasksCount" class="badge badge-light"/>
</a>
<br/>
<a href="{urlbase}/jobs" class="badge badge-light">
    <i class="fa fa-clock fa-fw"></i>
    Jobs <span id="jobsCount" class="badge badge-light"/>
</a>
<br/>
<a href="{urlbase}/forms" class="badge badge-light">
    <i class="fab fa-wpforms fa-fw"></i>
    Forms <span id="formsCount" class="badge badge-light"/>
</a>
{/if}
{#if info:isTracingEnabled}
<a href="{urlbase}/audit" class="badge badge-light">
    <i class="fab fa-wpforms fa-fw"></i>
    Audit investigation <span id="auditCount" class="badge badge-light"/>
</a>
{/if}
{#if info:isProcessEnabled == false && info:isTracingEnabled == false}
<p>No Kogito addons detected.</p>
{/if}
{#if info:isProcessEnabled}
<script>
    const fillCount = (resourceType) => {
        fetch("http://localhost:8080/dataindex/" + resourceType + "/count")
                .then(response => response.text())
                .then(count => {
                    document.getElementById(resourceType + "Count").innerText = count;
                }).catch(function () {
            console.log("Error while trying to fetch " + resourceType + " count.");
        });
    };

    fillCount("processInstances");
    fillCount("tasks");
    fillCount("jobs");
    fillCount("forms")
</script>
{/if}